home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / letters / finder / finder.sty < prev    next >
Text File  |  1992-02-25  |  6KB  |  226 lines

  1. % DOCUMENT OPTION STYLE
  2. %
  3. % This style has to be used as an optional style.
  4. %
  5. % Copyright (c) 1991,1992 by Steffen Steinhaeuser
  6. % Permission to copy all or part of this work is granted, provided
  7. % that the copies are not made or distributed for resale, and that
  8. % the copyright notice and this notice are retained.
  9. %
  10. % THIS WORK IS PROVIDED ON AN "AS IS" BASIS.  THE AUTHOR PROVIDES NO
  11. % WARRANTY WHATSOEVER, EITHER EXPRESS OR IMPLIED, REGARDING THE WORK,
  12. % INCLUDING WARRANTIES WITH RESPECT TO ITS MERCHANTABILITY OR FITNESS
  13. % FOR ANY PARTICULAR PURPOSE.
  14. %
  15. % If you make any improvements, I'd like to hear about them.
  16. %
  17. % Steffen Steinh\"auser
  18. % Landwehrstr. 47
  19. % 6100 Darmstadt
  20. % Federal Republic of Germany
  21. % steinhaeuser@ddagsi5.bitnet
  22. % steffen_steinhaeuser@mz.maus.de
  23. %
  24. \def~{ }
  25. \typeout{-------------------------------------------------------}
  26. \typeout{| FINDER.STY V2.1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|}
  27. \typeout{| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c'91 stone |}
  28. \typeout{-------------------------------------------------------}
  29.  
  30. \newif\ifstillmore
  31. \newif\iffoundname
  32. \newif\iffoundfirstname
  33. \newif\iffoundsecondname
  34.  
  35. \newif\iffindnameokay
  36. \findnameokayfalse
  37.  
  38. \newif\ifserienbrief
  39. \serienbrieffalse
  40.  
  41. \newread\datafile
  42.  
  43. \gdef\firstname{???\message{Kein 1.Suchwort definiert!}}
  44. \gdef\secondname{???\message{Kein 2. Suchwort definiert!}}
  45.  
  46. \def\meldung#1{
  47. \typeout{}
  48. \typeout{#1}
  49. \typeout{}}
  50.  
  51. \def\serienbrief#1{\long\def\serientext{#1}
  52. \meldung{Der Text des Serienbriefes wurde abgespeichert.}
  53. \serienbrieftrue
  54. \findnameokayfalse
  55. \foundnamefalse}
  56.  
  57. \def\findname{\DblArg{\findn@me}}
  58. \def\DblArg #1{\def\DAtemp{#1}\futurelet\DALook\Decide }
  59. \def\Decide{\ifx \DALook [  \let\DAdo=\DAtemp
  60.             \else           \let\DAdo=\DBarg    \fi \DAdo }
  61. \def\DBarg #1{\DAtemp[#1]{#1}}
  62.  
  63. \long\def\findn@me[#1]#2{ %
  64. \gdef\firstname{#1}
  65. \gdef\secondname{#2}
  66. \serienbrieffalse
  67. \ifx\firstname\@empty
  68.     \ifx\firstname\secondname
  69.         \meldung{Es wurden keine Suchdaten uebergeben !!!}
  70.         \findnameokayfalse
  71.     \else
  72.         \findnameokaytrue
  73.         \foundnamefalse
  74.         \global\edef\firstname{\secondname}
  75.     \fi
  76. \else
  77.     \ifx\secondname\@empty
  78.         \global\edef\secondname{\firstname}
  79.         \findnameokaytrue
  80.     \else
  81.     \findnameokaytrue
  82.     \foundnamefalse
  83.     \fi
  84. \fi}
  85.  
  86. \def\lookat#1 #2@@@{\gdef\found{#1}\gdef\rest{#2}
  87. \iffoundfirstname\else
  88.     \ifx\found\firstname
  89.         \foundfirstnametrue
  90.     \else
  91.         \foundfirstnamefalse
  92.     \fi
  93. \fi
  94. \iffoundsecondname\else
  95.     \ifx\found\secondname
  96.         \foundsecondnametrue
  97.     \else
  98.         \foundsecondnamefalse
  99.     \fi
  100. \fi
  101. \iffoundfirstname
  102.     \iffoundsecondname
  103.         \foundnametrue
  104.     \else
  105.         \ifx\rest\@empty\else
  106.             \expandafter\lookat\rest @@@
  107.         \fi
  108.     \fi
  109. \else
  110.     \ifx\rest\@empty\else
  111.         \expandafter\lookat\rest @@@
  112.     \fi
  113. \fi}
  114.  
  115. \def\addressfile#1{\gdef\filename{#1}
  116. \iffoundname
  117.     \meldung{Datei \filename~ wird nicht durchsucht !!!}
  118. \else
  119.     \foundnamefalse
  120.     \analysefile
  121.     \ifserienbrief
  122.     \foundnamefalse
  123.     \fi
  124. \fi}
  125.  
  126. \long\def\analysefile{ %
  127. \immediate\openin\datafile = \filename
  128. \iffindnameokay
  129.     \stillmoretrue
  130. \else
  131.     \ifserienbrief
  132.         \stillmoretrue
  133.         \foundnametrue
  134.     \else
  135.         \meldung{\string\findname{...}~ vor \string\addressfile~ aufrufen !!!}
  136.         \stillmorefalse
  137.     \fi
  138. \fi
  139. \message{finder.sty is searching in \filename}
  140. \loop
  141. \message{.}
  142. \foundfirstnamefalse
  143. \foundsecondnamefalse
  144. \ifeof\datafile\relax\else 
  145.     \immediate\read\datafile to \lineone
  146. \fi
  147. \ifeof\datafile\stillmorefalse\else
  148.     \gdef\name{\lineone}
  149.     \iffoundname\else
  150.         \if\endgraf\lineone
  151.             \gdef\name{\message{\string\name~ nicht definiert !!!}}
  152.         \else
  153.             \expandafter\lookat\lineone @@@
  154.         \fi
  155.     \fi
  156. \fi
  157. \ifeof\datafile\relax\else\immediate\read\datafile to \linetwo \fi
  158. \ifeof\datafile\stillmorefalse\else
  159.     \gdef\street{\linetwo}
  160.     \iffoundname\else
  161.         \if\endgraf\linetwo
  162.             \gdef\street{\message{\string\street~ nicht definiert !!!}}
  163.         \else
  164.             \expandafter\lookat\linetwo @@@
  165.         \fi
  166.     \fi
  167. \fi
  168. \ifeof\datafile\relax\else\immediate\read\datafile to \linethree \fi
  169. \ifeof\datafile\stillmorefalse\else
  170.     \gdef\city{\linethree}
  171.     \iffoundname\else
  172.         \if\endgraf\linethree
  173.             \gdef\city{\message{\string\city~ nicht definiert !!!}}
  174.         \else
  175.             \expandafter\lookat\linethree @@@
  176.         \fi
  177.     \fi
  178. \fi
  179. \ifeof\datafile\relax\else\immediate\read\datafile to \linefour \fi
  180. \ifeof\datafile\stillmorefalse\else
  181.     \gdef\telephone{\linefour}
  182.     \iffoundname\else
  183.         \if\endgraf\linefour
  184.             \gdef\telephone{\message{\string\telephone~ nicht definiert !!!}}
  185.         \else
  186.             \expandafter\lookat\linefour @@@
  187.         \fi
  188.     \fi
  189. \fi
  190. \ifeof\datafile\relax\else\immediate\read\datafile to \linefive \fi
  191. \ifserienbrief
  192.     \ifstillmore
  193.         \typeout{Adresse -> Serienbrief : \name}
  194.         \typeout{~~~~~~~~~~~~~~~~~~~~~~~~ \street}
  195.         \typeout{~~~~~~~~~~~~~~~~~~~~~~~~ \city}
  196.         \typeout{~~~~~~~~~~~~~~~~~~~~~~~~ \telephone}
  197.         \serientext
  198.     \else
  199.         \gdef\name{}
  200.         \gdef\street{}
  201.         \gdef\city{}
  202.         \gdef\telephone{}
  203.     \fi
  204. \else
  205.     \iffoundname
  206.         \stillmorefalse
  207.         \typeout{Adresse gefunden: ~~~~~~ \name}
  208.         \typeout{~~~~~~~~~~~~~~~~~~~~~~~~ \street}
  209.         \typeout{~~~~~~~~~~~~~~~~~~~~~~~~ \city}
  210.         \typeout{~~~~~~~~~~~~~~~~~~~~~~~~ \telephone}
  211.     \fi
  212. \fi
  213. \ifstillmore\else
  214.     \iffoundname\else
  215.         \foundnamefalse
  216.         \meldung{Datensatz nicht gefunden!!!}
  217.         \gdef\name{}
  218.         \gdef\street{}
  219.         \gdef\city{}
  220.         \gdef\telephone{}
  221.     \fi
  222. \fi
  223. \ifstillmore
  224. \repeat
  225. \closein\datafile}
  226.